home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-23 | 5.9 KB | 145 lines | [TEXT/PJMM] |
- {SATAddOnLib is a lib of the "Add-ons" that are easily put in a library (i.e. the ones without}
- {a "stubs" file). They include:}
- {}
- {GammaFade}
- {ProgressBar}
- {FaceFromPict}
- {SATToolbox}
- {Preferences}
-
- unit SATAddOnLib;
- interface
- uses
- {$IFC UNDEFINED THINK_PASCAL}
- Types, QuickDraw, Menus, ToolUtils, Resources, {}
- {$ENDC}
- SAT;
-
- {*** GammaFade ***}
- {Screen fading routines.}
-
- procedure FadeToBlack (ticks: Longint);
- procedure FadeFromBlack (ticks: Longint);
-
- {*** FaceFromPict ***}
- {Load a face from PICTs}
-
- function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
-
- {Pixel array types and routines}
- type
- Pixel = record
- position: Point;
- data1, data2, data3, data4: SignedByte;
- end;
- Pixels = array[0..32000] of Pixel;
- PixelPtr = ^Pixels;
-
- procedure SATDrawPixels (pix: PixelPtr; var port: SATPort; value: Longint);
- procedure SATCopyPixels (pix: PixelPtr; var src, dest: SATPort);
- procedure SATDrawPixelsSafe (pix: PixelPtr; var port: SATPort; value: Longint);
- procedure SATCopyPixelsSafe (pix: PixelPtr; var src, dest: SATPort);
-
- {*** Preferences ***}
- {Create a preference file in the Preferences folder.}
-
- {Open the pref file if needed. Return the variables appFile and prefFile.}
- {If alwaysExternal is true, we always want a pref file in the system folder even if we can save in the application.}
- {Returns true if a new prefFile was created.}
- function SetPrefFile (prefsFileName: Str255; prefCreator, prefType: OSType; var appFile, prefFile: Integer; alwaysExternal: Boolean): Boolean;
-
- {Copy a resource from one file to another. Useful when SetPrefFile returns true!}
- function CopyResource (fromFile, toFile: integer; theResType: ResType; id: integer): OSErr;
-
- {*** ProgressBar ***}
- {An adaptive progress bar, adjusts itself automatically by remembering how much time the}
- {time-consuming operation took last time.}
-
- {Note: The full type declarations are removed to make this brief. See ProgressBar.p if you need them.}
- type
- ProgressBarColorPtr = Ptr;
- ProgressBarPtr = Ptr;
-
- function InitProgressBar (prefFile, resID: Integer; bounds: Rect; colors: ProgressBarColorPtr): ProgressBarPtr;
- function ProgressBarColors (frameRed, frameGreen, frameBlue, backRed, backGreen, backBlue, foreRed, foreGreen, foreBlue: Integer): ProgressBarColorPtr;
- function ProgressBarColorsRGB (frame, back, fore: RGBColor): ProgressBarColorPtr;
- procedure AdvanceProgressBar (thePB: ProgressBarPtr);
- procedure FinishProgressBar (thePB: ProgressBarPtr);
-
- {*** SATToolbox ***}
- {Some sprite handling routines, plus some math routines.}
-
- {The following switch should be true if your SAT.p has a fixedPointPosition field.}
- {MUST MATCH THE FLAG IN SATToolbox.p WHEN THE LIB WAS COMPILED!}
- {$setc _hasfixedpoint = true}
-
- type
- FixSpritePtr = ^FixSprite;
- FixSprite = record
- { Variables that you should change as appropriate }
- kind: Integer; { Used for identification. >0: friend. <0 foe }
- position: Point;
- hotRect, hotRect2: Rect; { Tells how large the sprite is; hotRect is centered around origo }
- {hotRect is set by you. hotRect2 is offset to the current position.}
- face: FacePtr; { Pointer to the Face (appearance) to be used. }
- task: ProcPtr; { Callback-routine, called once per frame. If task=nil, the sprite is removed. }
- hitTask: ProcPtr; { Callback in collisions. }
- destructTask: ProcPtr; { Called when a sprite is disposed. (Usually nil.) }
- clip: RgnHandle; {Clip region to be used when this sprite is drawn.}
- { SAT variables that you shouldn't change: }
- oldpos: Point; {Used by RunSAT2}
- next, prev: SpritePtr; {You may change them in your own sorting routine, but be careful if you do.}
- r, oldr: Rect; {Rectangle telling where to draw. Avoid messing with it.}
- oldFace: FacePtr; {Used by RunSAT2}
- dirty: Boolean; {Used by RunSAT2}
- {Variables for internal use by the sprites. Use as you please. Edit as necessary - this is merely a default}
- {set, enough space for most cases - but if you change the size of the record, call SetSpriteSize immediately}
- {after initializing (before any sprites are created)!}
- layer: integer; {For layer-sorting. When not used for that, use freely.}
- speed: Point; { Can be used for speed, but not necessarily. }
- mode: integer; { Usually used for different modes and/or to determine what image to show next. }
- fixedPointPosition: Point; {fixed point position}
- appLong: Longint; {Longint for free use by the application.}
- end;
-
- {Constants for separation/bounceoff between sprites}
- const
- kPushBoth = 0;
- kPushMe = 1;
- kPushHim = 2;
-
- (*Sprite utilities*)
- procedure MoveSprite (theSprite: SpritePtr);
- function KeepOnScreen (theSprite: SpritePtr): Boolean;
- {$ifc _hasfixedpoint}
- procedure MoveSpriteFixedPoint (theSprite: FixSpritePtr);
- function KeepOnScreenFixed (theSprite: FixSpritePtr): Boolean;
- {$endc}
- function RectSeparate (theSprite: SpritePtr; anotherSprite: SpritePtr; push: Integer): Integer;
- procedure RectBounce (me, him: SpritePtr; push: Integer);
- procedure RectBounceFixed (me, him: FixSpritePtr; push: Integer);
- function PtInSpriteRgn (p: Point; theSprite: SpritePtr): Boolean;
- function RegionHit (theSprite: SpritePtr; anotherSprite: SpritePtr): Boolean;
- procedure SplitVector (v: Point; d: Point; var p: Point; var n: Point);
-
- procedure RegionBounce (s1, s2: FixSpritePtr);
-
- {*** Look-up table based fixed-point math operations. ***}
- {Good for high-speed trig functions on 68k Macs. (Not tested too much yet.)}
-
- {Don't change these constants without recompiling the lib!}
- const
- kFixedPointShift = 4; {Number of fixed-point positions}
- kFixedOne = 16; {The "one" in the fixed-point system being used!}
-
- procedure InitTables; {Init not required}
- function SquareRoot (arg: Longint): Longint;
- function Sinus (arg: Longint): Longint;
- function Cosinus (arg: Longint): Longint;
- function VectorLength (vector: Point): Longint;
- function FPVectorLength (vector: Point): Longint;
-
-
-
- implementation
- end.